<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.0.2/vue.global.js"></script>
</head>
<body>
    <div id="app"></div>
</body>
<script>
    const app = Vue.createApp({
        data(){
            return{
                count:0
            }
        },
        methods:{

        },
        template:`<counter :count="count"/>`
    })
    app.component('counter',{
        props:['count']
        ,data(){
            return{
                newcount: this.count
            }
        }
        ,methods:{
            addcount(){
                this.newcount+=1;
            }
        }
        ,template:`{{newcount}}<button @click="addcount">按钮</button>`
    })
    app.mount("#app")
</script>
</html>